const {
	userCollection
} = require('../../common/constants')
const {
	ERROR
} = require('../../common/error')

/**
 * 获取账户账户信息
 * @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#get-account-info
 */
module.exports = async function(params = {}) {
	const schema = {
		uid: 'string'
	}
	this.middleware.validate(params, schema)
	const {
		uid
	} = params
	const userRes = await userCollection.where({
		_id: uid
	}).get()
	const userRecord = userRes && userRes.data && userRes.data[0] ? userRes.data[0] : {}
	return {
		errCode: 0,
		userRecord: userRecord
	}
}